/**
 * 
 */
package com.novartis.nims.imagedc.util;

import java.io.File;

/**
 * @author snydejo2
 *
 */
public class Filesystem {
	
	//TODO: pass a callback object for progress updates
	public static long sizeInBytes(File file) {
		long totalBytes = 0;
		
		RecursiveFileListIterator fileIterator = new RecursiveFileListIterator(file);
		//TODO: check for cancellation on callback object
		while (fileIterator.hasNext() /*&& (!this.isCancelled())*/) {
			File childFile = fileIterator.next();
			totalBytes += childFile.length();
			
			// HACK can't calculate determinate progress, so keep updating with a
			// repeating iteration from 1 to 99
			//TODO: call progress update on callback object
			//this.setProgress(Math.max(1, Math.min(99, ((int) totalBytes % 100))));
		}
		
		return totalBytes;
	}

}
